<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>报表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link rel="stylesheet" href="${pageContext.request.contextPath}/homepages/css/main.css" type="text/css"></link>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/icon.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.1.2.2.js"></script>
    
	 <script type="text/javascript">
	 
	 			
    	$(function(){
 			$('#dd').datagrid({
				iconCls:'icon-save',
				nowrap: false,
				striped: true,				 
				collapsible:true,
				autoRowHeight: false,		
				sortName: 'code',
				sortOrder: 'desc',
				remoteSort: false,
				idField:'code',
				fitColumns:true,
				columns:[[]],
				pagination:true,
				rownumbers:true,
				toolbar:[{
					id:'btnadd',
					text:'Add',
					iconCls:'icon-add',
					handler:function(){
						$('#btnsave').linkbutton('enable');
						$('#dd').dialog({
							'open':true,
							'modal':true
						});
					}
				},{
					id:'btncut',
					text:'Cut',
					iconCls:'icon-cut',
					handler:function(){
						$('#btnsave').linkbutton('enable');
						alert('cut')
					}
				},'-',{
					id:'btnsave',
					text:'Save',
					disabled:true,
					iconCls:'icon-save',
					handler:function(){
						$('#btnsave').linkbutton('disable');
						alert('save')
					}
				}]
				});
				loadCol();
		});
	
		function loadCol(){
		 	var formId = $('#formId').val();
			$.ajax({
				type:'post',
				url:'../report/queryList',	
				data:{'formId':formId},
				dataType:'json',
				success:function(data){
					 var options = {  
							width: "auto",  
							height: "auto",  
							rownumbers: true  
						};  
					var columns = new Array();
					for(var i = 0; i < data.columns.length; i++){
						var column = {};
						column.title = data.columns[i].colnName
						column.field = data.columns[i].name;
						columns[i] = column;
					}
					var cc = new Array();
					cc[0] = columns;
					options.columns = (cc);
					$('#dd').datagrid(options);//根据配置选项，生成datagrid  
					$('#dd').datagrid("loadData", data);
				}
			});
		}
	 </script>

  </head>
  
  <body>
  	<div id="dd"></div>
  	<input type="hidden" id="formId" value="${formId }"/>
  </body>
</html>
